package com.brave.notice.controller;

import com.brave.base.BaseController;
import com.brave.base.CheckNullParamKit;
import com.brave.base.RedisKit;
import com.brave.notice.dto.FindMyNoticeListDTO;
import com.brave.notice.service.NoticeQueryService;
import com.brave.user.dto.RedisUserInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 2019年10月8日 14:43:46
 * 通知公告模块
 */
@Api(value = "通知公告部分", tags = "通知公告部分", description = "通知公告部分")
@RestController
@RequestMapping("/v1/notice")
public class NoticeQueryController extends BaseController
{
    @Autowired
    private RedisKit redisKit;
    @Autowired
    private NoticeQueryService noticeQueryService;
    
    
    
    @ApiOperation(value = "查询我的通知列表")
    @ApiImplicitParam(name = "dto", value = "查询参数", required = true, dataType = "FindMyNoticeListDTO")
    @PostMapping(value = "/findMyNoticeList", produces = "application/json")
    public String findMyNoticeList(@RequestHeader String token, @RequestBody FindMyNoticeListDTO dto)
    {
        //校验身份
        RedisUserInfo redisUserInfo = redisKit.checkUserToken(token);
        if(null == redisUserInfo)
        {
            return tokenBadRequest();
        }
        //校验参数
        Map<String, String> checkMap = CheckNullParamKit.checkParam(dto);
        if(0 != checkMap.size())
        {
            return badParameter(checkMap);
        }
        //调用业务逻辑
        return noticeQueryService.findMyNoticeList(redisUserInfo, dto);
    }
    
    
    
    
    
    
    
    
    
    
    
}